home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / vidhrdw / fastlane.c < prev    next >
C/C++ Source or Header  |  2000-04-04  |  4KB  |  137 lines

  1. #include "driver.h"
  2. #include "vidhrdw/konamiic.h"
  3. #include "vidhrdw/generic.h"
  4.  
  5. unsigned char *fastlane_k007121_regs,*fastlane_videoram1,*fastlane_videoram2;
  6. static struct tilemap *layer0, *layer1;
  7.  
  8. /***************************************************************************
  9.  
  10.   Callbacks for the TileMap code
  11.  
  12. ***************************************************************************/
  13.  
  14. static void get_tile_info0(int tile_index)
  15. {
  16.     int attr = fastlane_videoram1[tile_index];
  17.     int code = fastlane_videoram1[tile_index + 0x400];
  18.     int bit0 = (K007121_ctrlram[0][0x05] >> 0) & 0x03;
  19.     int bit1 = (K007121_ctrlram[0][0x05] >> 2) & 0x03;
  20.     int bit2 = (K007121_ctrlram[0][0x05] >> 4) & 0x03;
  21.     int bit3 = (K007121_ctrlram[0][0x05] >> 6) & 0x03;
  22.     int bank = ((attr & 0x80) >> 7) |
  23.             ((attr >> (bit0+2)) & 0x02) |
  24.             ((attr >> (bit1+1)) & 0x04) |
  25.             ((attr >> (bit2  )) & 0x08) |
  26.             ((attr >> (bit3-1)) & 0x10) |
  27.             ((K007121_ctrlram[0][0x03] & 0x01) << 5);
  28.     int mask = (K007121_ctrlram[0][0x04] & 0xf0) >> 4;
  29.  
  30.     bank = (bank & ~(mask << 1)) | ((K007121_ctrlram[0][0x04] & mask) << 1);
  31.  
  32.     SET_TILE_INFO(0,code+bank*256,1);
  33. }
  34.  
  35. static void get_tile_info1(int tile_index)
  36. {
  37.     int attr = fastlane_videoram2[tile_index];
  38.     int code = fastlane_videoram2[tile_index + 0x400];
  39.     int bit0 = (K007121_ctrlram[0][0x05] >> 0) & 0x03;
  40.     int bit1 = (K007121_ctrlram[0][0x05] >> 2) & 0x03;
  41.     int bit2 = (K007121_ctrlram[0][0x05] >> 4) & 0x03;
  42.     int bit3 = (K007121_ctrlram[0][0x05] >> 6) & 0x03;
  43.     int bank = ((attr & 0x80) >> 7) |
  44.             ((attr >> (bit0+2)) & 0x02) |
  45.             ((attr >> (bit1+1)) & 0x04) |
  46.             ((attr >> (bit2  )) & 0x08) |
  47.             ((attr >> (bit3-1)) & 0x10) |
  48.             ((K007121_ctrlram[0][0x03] & 0x01) << 5);
  49.     int mask = (K007121_ctrlram[0][0x04] & 0xf0) >> 4;
  50.  
  51.     bank = (bank & ~(mask << 1)) | ((K007121_ctrlram[0][0x04] & mask) << 1);
  52.  
  53.     SET_TILE_INFO(0,code+bank*256,0);
  54. }
  55.  
  56. /***************************************************************************
  57.  
  58.     Start the video hardware emulation.
  59.  
  60. ***************************************************************************/
  61.  
  62. int fastlane_vh_start(void)
  63. {
  64.     layer0 = tilemap_create(get_tile_info0,tilemap_scan_rows,TILEMAP_OPAQUE,8,8,32,32);
  65.     layer1 = tilemap_create(get_tile_info1,tilemap_scan_rows,TILEMAP_OPAQUE,8,8,32,32);
  66.  
  67.     tilemap_set_scroll_rows( layer0, 32 );
  68.  
  69.     if (!layer0 || !layer1)
  70.         return 1;
  71.  
  72.     {
  73.         struct rectangle clip = Machine->drv->visible_area;
  74.         clip.min_x += 40;
  75.         tilemap_set_clip(layer0,&clip);
  76.  
  77.         clip.max_x = 39;
  78.         clip.min_x = 0;
  79.         tilemap_set_clip(layer1,&clip);
  80.  
  81.         return 0;
  82.     }
  83. }
  84.  
  85. /***************************************************************************
  86.  
  87.   Memory Handlers
  88.  
  89. ***************************************************************************/
  90.  
  91. WRITE_HANDLER( fastlane_vram1_w )
  92. {
  93.     if (fastlane_videoram1[offset] != data)
  94.     {
  95.         tilemap_mark_tile_dirty(layer0,offset & 0x3ff);
  96.         fastlane_videoram1[offset] = data;
  97.     }
  98. }
  99.  
  100. WRITE_HANDLER( fastlane_vram2_w )
  101. {
  102.     if (fastlane_videoram2[offset] != data)
  103.     {
  104.         tilemap_mark_tile_dirty(layer1,offset & 0x3ff);
  105.         fastlane_videoram2[offset] = data;
  106.     }
  107. }
  108.  
  109.  
  110.  
  111. /***************************************************************************
  112.  
  113.   Screen Refresh
  114.  
  115. ***************************************************************************/
  116.  
  117. void fastlane_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
  118. {
  119.     int i, xoffs;
  120.  
  121.     /* set scroll registers */
  122.     xoffs = K007121_ctrlram[0][0x00];
  123.     for( i=0; i<32; i++ ){
  124.         tilemap_set_scrollx(layer0, i, fastlane_k007121_regs[0x20 + i] + xoffs - 40);
  125.     }
  126.     tilemap_set_scrolly( layer0, 0, K007121_ctrlram[0][0x02] );
  127.  
  128.     tilemap_update( ALL_TILEMAPS );
  129.     if (palette_recalc())
  130.         tilemap_mark_all_pixels_dirty(ALL_TILEMAPS);
  131.     tilemap_render( ALL_TILEMAPS );
  132.  
  133.     tilemap_draw(bitmap,layer0,0);
  134.     K007121_sprites_draw(0,bitmap,spriteram,0,40,0,-1);
  135.     tilemap_draw(bitmap,layer1,0);
  136. }
  137.